window.addEventListener("load", equalScaling, false);
window.addEventListener("resize", equalScaling, false);

/* =函数定义
-----------------------------------------------------------------------------*/
function equalScaling() {
	switch(document.body.clientWidth) {
		case 320:
		case 360:
		case 375:
		case 768:
			document.getElementsByTagName("html")[0].style.fontSize = "";
			break;
		default:
			calcHTMLFontSize();
	}
}

/* =表单发送
-----------------------------------------------------------------------------*/
function sendApplyForm() {
	var request = new XMLHttpRequest();
	request.open("POST", "//bitshe.cn/apply/apply.php");

	var data =
		"name=" + document.querySelector("input[name='name']").value +
		"&no=" + document.querySelector("input[name='no']").value +
		"&department=" + document.querySelector("input[name='department']").value +
		"&class=" + document.querySelector("input[name='class']").value +
		"&qq=" + document.querySelector("input[name='qq']").value +
		"&tel=" + document.querySelector("input[name='tel']").value +
		"&skill=" + document.querySelector("input[name='skill']").value +
		"&expect=" + document.querySelector("input[name='expect']").value;
//	console.log(data);
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	request.send(data);
	request.onreadystatechange = function() {
		if(request.readyState === 4) {
			if(request.status === 200) {
//				console.log(request.responseText);
				var retJSON = JSON.parse(request.responseText);
				alert(retJSON.msg);
				window.location.href = 'https://jq.qq.com/?_wv=1027&k=5EV0eoO';
			} else {
				alert("状态：" + request.status);
			}
		}
	}
	return false;
}

document.getElementById('departmentSelect')
		.addEventListener('change', function (e) {
			var selectBox = e.target;
			var currentIndex = selectBox.selectedIndex;			
			document.querySelector("input[name='department']").value = selectBox.options[currentIndex].text;
		});